import { _decorator, Component, Node, Button } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('BtnAgainTimeComponent')
export class BtnAgainTimeComponent extends Component {


    start() {
        this.node.on(Node.EventType.TOUCH_END, this.OnClickBtn, this);
    }

    onEnable(){
        this.UpdateBtnInteractable(true);
    }

    UpdateBtnInteractable(active) {
        this.node.getComponent(Button).enabled = active;
        this.node.getComponent(Button).interactable = active;
    }

    OnClickBtn() {
        console.log("OnClickBtn");
        this.unscheduleAllCallbacks();
        let myThis = this;
        myThis.UpdateBtnInteractable(false);
        this.scheduleOnce(function () {
            myThis.UpdateBtnInteractable(true);
        }.bind(this), 3);
    }

    onDestroy() {
        this.unscheduleAllCallbacks();
    }

}

